import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import local_get from '@dfeidao/atom-web/local/get';
import local_remove from '@dfeidao/atom-web/local/remove';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import msg_error from '@dfeidao/atom-web/msgbox/error';
import error from '@dfeidao/atom-web/msgbox/error';
import success from '@dfeidao/atom-web/msgbox/success';
// import whoami from '@dfeidao/atom-web/msg/whoami';
import storage_get from '@dfeidao/atom-web/storage/get';
import a001 from './a001';
// 删除
export default async function a004(fd: IFeidaoAiBrowserComponent) {
	const pub_form_code = local_get(fd, 'pub_form_code') as { formid: string, code: string };
	if (pub_form_code) {
		// const user = await whoami();
		const prid = storage_get('productid');
		const res = await nodejs('function-definition/zj-000002/s002', { formid: pub_form_code.formid, code: pub_form_code.code, productid: prid });
		if (res === "fail") {
			error("删除失败");
		}
		if (res === "success") {
			success("删除成功");
			local_remove(fd, 'pub_form_code');
			await a001(fd);
		}
	} else {
		msg_error("请选择一行数据");
	}
}
